<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>product</title>
  <script type="text/javascript" src="../frame/assets/js/lib/jquery.min.js"></script>
  <script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
  <script src="../frame/layui/lay/modules/layer.js"></script>
  <link rel="stylesheet" href="../frame/layui/lay/modules/layer/default/layer.css">
  <link rel="stylesheet" href="../frame/layui/css/layui.css"  media="all">
  <link rel="stylesheet" href="../frame/assets/css/lib/bootstrap.min.css">
  <link rel="stylesheet" href="../frame/assets/css/lib/font-awesome.min.css">
  <link rel="stylesheet" href="../frame/assets/css/lib/themify-icons.css">
  <link rel="stylesheet" href="../frame/assets/css/lib/unix.css">
  <link rel="stylesheet" href="../frame/assets/css/style.css">
  <link rel="stylesheet" href="../frame/assets/css/lib/menubar/sidebar.css">
  <link rel="stylesheet" href="../frame/assets/css/lib/sweetalert/sweetalert.css">
</head>
<body>
<div class="content-wrap">
  <div class="main">
    <div class="container-fluid">
      <!--欢迎栏-->
      <div class="row">
        <div class="col-lg-8 p-r-0 title-margin-right">
          <div class="page-header">
            <div class="page-title">
              <h1>资产调动管理</h1>

              <!-- <span>先编辑，后借用</span> -->
            </div>
          </div>
        </div>
      </div>
      <table id="demo1" lay-filter="test1"></table>
      <br><br>
    </div>
  </div>
</div>
<!--搜索-->
<div id="search">
  <button type="button" class="close">×</button>
  <form>
    <input type="search" value="" placeholder="type keyword(s) here" />
    <button type="submit" class="btn btn-primary">Search</button>
  </form>
</div>
<script type="text/html" id="barDemo1">
  <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">撤销</a>

</script>
<script src="../frame/assets/js/lib/jquery.min.js"></script>
<script src="../frame/assets/js/lib/jquery.nanoscroller.min.js"></script>
<script src="../frame/assets/js/lib/menubar/sidebar.js"></script>
<script src="../frame/assets/js/lib/bootstrap.min.js"></script>
<script src="../frame/assets/js/lib/data-table2/datatables.min.js"></script>
<script src="../frame/assets/js/lib/data-table2/dataTables.buttons.min.js"></script>
<script src="../frame/assets/js/lib/data-table2/buttons.flash.min.js"></script>
<script src="../frame/assets/js/lib/data-table2/jszip.min.js"></script>
<script src="../frame/assets/js/lib/data-table2/pdfmake.min.js"></script>
<script src="../frame/assets/js/lib/data-table2/vfs_fonts.js"></script>
<script src="../frame/assets/js/lib/data-table2/buttons.html5.min.js"></script>
<script src="../frame/assets/js/lib/data-table2/buttons.print.min.js"></script>
<script src="../frame/assets/js/lib/data-table2/datatables-init2.js"></script>
<script src="../frame/assets/js/lib/sweetalert/sweetalert.min.js"></script>
<script src="../frame/assets/js/lib/sweetalert/zhuxiao.js"></script>
<script type="text/javascript" src="../frame/layui/layui.js" charset="utf-8"></script>

<script>
  layui.use('table', function() {
    var table = layui.table;
    //第一个实例
    table.render({
      elem: '#demo1'
      , height: '450px'
      , url: 'http://localhost:8080/useproduct' //数据接口
      , method: 'get'
      , page: true //开启分页
      , cols: [[ //表头
        {field: 'id', width: 90, title: 'ID编号', sort: true, fixed: 'left'}
        , {field: 'sname', width: 120, title: '资产名称'}
        , {field: 'sperson', width: 100, title: '审核人'}
        , {field: 'speople', width: 100, title: '借调人'}
        , {field: 'zczt', width: 100, title: '资产状态'}
        , {field: 'sbegint', width: 120, title: '借出日期', sort: true}
        , {field: 'scondition', width: 90, title: '状态'}
        , {field: 'right', width: 120, title: '操作', toolbar: '#barDemo1'}
      ]]
    });
    table.on('tool(test1)', function(obj){
      var data = obj.data;var sid=data.id;
      if(obj.event === 'del'){
        layer.confirm('确认撤销吗？', function(index){
          var aa = "http://localhost:8080/useproduct1/"+obj.data.id;
          console.log(obj.data.id);
          $.ajax({
            url: aa,
            type: "POST",
            data:{"id":obj.data.id},
            dataType: "json",
          });
          obj.del();
          //关闭弹框
          layer.close(index);
          layer.msg("撤销成功", {icon: 6});
        });
      }

      //监听单元格编辑
    });
  });


</script>
</body>
</html>